package com.web.rss;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.List;

import com.sun.syndication.feed.synd.SyndEntryImpl;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.FeedException;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;


public class Reader {

	public Reader () {
		
	}
	
	
	@SuppressWarnings("unchecked")
	public static void main (String args[]) {
		
		URL feedUrl;
		SyndFeedInput input = new SyndFeedInput();
		SyndFeed feed;
		List<SyndEntryImpl> entries;
		Iterator<SyndEntryImpl> iter;
		
		try {
			feedUrl = new URL("http://www.lemonde.fr/rss/sequence/0,2-3246,1-0,0.xml");
			feed = input.build(new XmlReader(feedUrl));
			System.out.println(feed.getTitle());
			System.out.println(feed.getDescription());
			entries = feed.getEntries();
			iter = entries.iterator();
			SyndEntryImpl curr;
			int i = 0;
			while ((iter.hasNext()) && (i <= 10 )) {
				curr = iter.next();
				System.out.println(curr.getTitle());
				i++;
			}
		}
		catch (MalformedURLException mURLex) {
			
		}
		catch (IOException ioex) {
			
		}
		catch (FeedException fex) {
			
		}
		
	}
}
